/*
 * 天虹商场股份有限公司版权所有.
 */
package com.rainbow.hmkmybatis.config;

import com.rainbow.beans.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * TODO
 *
 * @author 黄明坤
 * @version 1.0.0
 * @date 2020/6/28
 */
public class MapperRegistory {

    public static final Map<String, MapperRegistory.MapperData> methodSqlMapping = new HashMap<>();


    //使用 1. 在这里配置
    //2. Java Bean的属性名字要和数据库表的名字一致
    public MapperRegistory() {
        methodSqlMapping.put("com.rainbow.mapper.TestMapper.selectByPrimaryKey",
                new MapperRegistory.MapperData("select * from test where id = %d", Test.class));
    }


    /**
     * 接口的信息
     * @param <T>
     */
    public class MapperData<T>{
        private String sql;
        private Class<T> type;

        public MapperData(String sql, Class<T> type) {
            this.sql = sql;
            this.type = type;
        }

        public String getSql() {
            return sql;
        }

        public void setSql(String sql) {
            this.sql = sql;
        }

        public Class<T> getType() {
            return type;
        }

        public void setType(Class<T> type) {
            this.type = type;
        }
    }

    public MapperRegistory.MapperData get(String nameSpace) {
        return methodSqlMapping.get(nameSpace);
    }
}
